<% todo = edit_form -%>
<%= form_for(todo, :html=> { :name=>'todo', :id => dom_id(@todo, 'form'), :class => 'inline-form edit_todo_form' }) do |t|%>
  <div id="edit_error_status">
  <% if todo.errors.any? -%>
    <ul>
      <% todo.errors.full_messages.each do |msg| %>
      <li><%= msg %></li>
      <% end %>
    </ul>
  <% end -%>
  </div>

  <%= t.hidden_field( "id" ) -%>
  <%= source_view_tag( @source_view ) -%>
  <%= content_tag(:input, "", :type=>"hidden", :name=>"_tag_name", :value=>"#{@tag_name}") if @tag_name -%>

  <label for="<%= dom_id(@todo, 'description') %>"><%= t('common.description') %></label>
  <%= t.text_field( "description", "size" => 30, "maxlength" => 100) %>

  <label for="<%= dom_id(@todo, 'notes') %>"><%= t('common.notes') %></label>
  <%= t.text_area( "notes", "cols" => 29, "rows" => 4) %>

  <div class="project_input">
    <label for="<%= dom_id(@todo, 'project_name') %>"><%= t('common.project') %></label>
    <input id="<%= dom_id(@todo, 'project_name') %>" name="project_name" autocomplete="off" size="30" type="text" value="<%= @todo.project.nil? ? '' : h(@todo.project.name) %>" />
  </div>

  <div class="context_input">
    <label for="<%= dom_id(@todo, 'context_name') %>"><%= t('common.context')  %></label>
    <input id="<%= dom_id(@todo, 'context_name') %>" name="context_name" autocomplete="off" size="30" type="text" value="<%= h @todo.context.name %>" />
  </div>

  <label class="tag_list_label" for="<%= dom_id(@todo, 'tag_list') %>"><%= t('todos.tags') %></label>
  <%= text_field_tag 'tag_list', tag_list_text, :id => dom_id(@todo, 'tag_list'), :size => 30 %>

  <div class="due_input">
    <label for="<%= dom_id(@todo, 'due_label') %>"><%= Todo.human_attribute_name('due') %></label>
    <%= date_field_tag("todo[due]", dom_id(@todo, 'due'), format_date(@todo.due)) %>
    <a href="#" id="<%= dom_id(@todo, 'due_x') %>" class="date_clear" title="<%= t('todos.clear_due_date') %>">
      <%= image_tag("blank.png", :alt => t('todos.clear_due_date'), :class => "delete_item") %>
    </a>
  </div>

  <div class="show_from_input">
    <label for="<%= dom_id(@todo, 'show_from') %>"><%= t('todos.show_from') %></label>
    <%= date_field_tag("todo[show_from]", dom_id(@todo, 'show_from'), format_date(@todo.show_from)) %>
    <a href="#" id="<%= dom_id(@todo, 'show_from_x') %>" class="date_clear" title="<%= t('todos.clear_show_from_date') %>">
      <%= image_tag("blank.png", :alt => t('todos.clear_show_from_date'), :class => "delete_item") %>
    </a>
  </div>

  <div class="depends_on">
    <label for="predecessor_ul"><%= Todo.human_attribute_name('predecessors')%></label>
    <div class="selected_predecessors">
      <ul class="predecessor_list" id="predecessor_ul" style="display:<%= @todo.predecessors.empty? ? "none" : "block"%>">
      </ul>
    </div>
    <label id="label_for_predecessor_input" for="predecessor_input" style="display:none"><%= t('todos.add_another_dependency')%></label>
    <%= text_field_tag "predecessor_input", nil, :size => 30 %>
    <%= hidden_field_tag "predecessor_list", @todo.predecessors.map{|t| t.id.to_s}.join(', ') %>
  </div>


  <div class="submit_box">
    <div class="widgets">
      <button type="submit" class="positive" id="<%= dom_id(@todo, 'submit') %>">
        <%=image_tag("accept.png", :alt => "") %>
        <%= t('common.update') %>
      </button>
      <a href="#" class="negative">
        <%=image_tag("cancel.png", :alt => "") %>
        <%= t('common.cancel') %>
      </a>
    </div>
  </div>

<% end %>
